package com.yesep.learn.netty.protocol.common;

/**
 * @Description: 请求命令类型
 */
public enum CN_TYPE {

	PARAMETER(1, "参数命令"), DATA(2, "数据命令"), CONTROL(3, "控制命令"), INTERACTIVE(4, "交互命令");

	private Integer code;//编号
	private String message;//描述

	private CN_TYPE(Integer code, String message) {
		this.code = code;
		this.message = message;
	}

	public Integer getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	@Override
	public String toString() {
		return this.name() + "(" + this.code + " | " + this.message + ")";
	}

	public static CN_TYPE get(int code) {
		for (CN_TYPE e : CN_TYPE.values()) {
			if (e.getCode() == code) {
				return e;
			}
		}
		return null;
	}
}
